import java.util.ArrayList;


public class CustomerAccount
{

	private int accountID;
	private String name;
	private String address;
	private String email;
	private String phone;
	private ArrayList<Integer> rented;
	private ArrayList<Integer> daysRented;
	private AccountState state;
	private Membership membership;
	private ArrayList<Item> shoppingcart;

	public CustomerAccount(int i,String n, String add, String e,  String p)
	{
		accountID=i;
		name=n;
		address=add;
		email=e;
		phone=p;
		rented=new ArrayList<Integer>();
		daysRented=new ArrayList<Integer>();
        state=new GoodStanding(this);
        membership=new CopperMember(this);
        shoppingcart=new ArrayList<Item>();        
	}
	
	public void addToCart(Item i)
	{
		shoppingcart.add(i);
		addRentedItem(i.getID());
	}
	public boolean returnedItem(int i)
	{
		int numDaysRented=getDaysRented(i);
		if(numDaysRented>-1)
		{
			removeRentedItem(i);
			if(membership.calculateLatePayment(numDaysRented)>0)
			System.out.println("You owe "+membership.calculateLatePayment(numDaysRented)+" for being late.");
			new RentPayment(this).processPayment(membership.calculateLatePayment(numDaysRented));
			return true;
		}
		System.out.println("You didn't rent this item");
		return false;
	}
	public void addRentedItem(int i)
	{
		rented.add(i);
		daysRented.add(0);
	}
	private void removeRentedItem(int i)
	{
		if(rented.indexOf(i)>=0) 
		{
			daysRented.remove(rented.indexOf(i));
		    rented.remove(rented.indexOf(i));
		}
	}
	private int getDaysRented(int i)
	{
		if(daysRented.indexOf(i)>=0)
		{
			return daysRented.get(rented.indexOf(i));
		}
		return -1;
	}
	public void addDayRented()
	{
		for(int i=0; i<daysRented.size(); i++)
		{
			daysRented.set(i, daysRented.get(i)+1);
		}
	}
	public void sendNotification()
	{
		Notification notification=new Notification(this);
		notification.generateNotification();
		notification.notifyCustomer();
	}
	
	public int getAccountID() {
		return accountID;
	}

	public void setAccountID(int accountID) {
		this.accountID = accountID;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}


	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public ArrayList<Integer> getRented() {
		return rented;
	}

	public void setRented(ArrayList<Integer> rented) {
		this.rented = rented;
	}

	public AccountState getState() {
		return state;
	}

	public void setState(AccountState state) {
		this.state = state;
	}

	public Membership getMembership() {
		return membership;
	}

	public void setMembership(Membership membership) {
		this.membership = membership;
	}

	public ArrayList<Item> getShoppingCart() {
		// TODO Auto-generated method stub
		return shoppingcart;
	}
	
}
